package com.atguigu.gmall.seckill.executor;

import com.atguigu.gmall.seckill.properties.XXLJobProperties;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class XxlJobExecutorConfiguration {

    @Autowired
    private XXLJobProperties xxlJobProperties ;

    @Bean
    public XxlJobSpringExecutor xxlJobSpringExecutor() {
        XxlJobSpringExecutor executor = new XxlJobSpringExecutor() ;
        executor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
        executor.setAccessToken(xxlJobProperties.getAccessToken());
        executor.setIp(xxlJobProperties.getIp());
        executor.setPort(xxlJobProperties.getPort());
        executor.setAppname(xxlJobProperties.getAppName());
        return executor;
    }

}
